<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>

<?php 
	$TOURNAMENT = $this->tournament_entity->init('id', intval($_GET['t_id']));
	if(!$TOURNAMENT){
		show_404();
		exit();
	}
?>
	
<div id="center_content">
	<div class="clrboth"></div>
	<div class="block">
		<div class="title" style="position:relative;">
			<h3 class="bold">Winners</h3>
			<a class="back_button2" href="<?php echo site_url("cricket/user/winners")?>" title="Back?">Back?</a>
		</div>
		
		<div class="clrboth"></div>
		
			<div class="content">
				
					<?php $prize_array = $this->prize_entity->getArrayListOfPrize($TOURNAMENT->getId()); ?>
					<?php if(count($prize_array) AND $TOURNAMENT->getIsFinish() == 'yes') : ?>
						<?php foreach($prize_array as $item): ?>	
							<?php 
								$USER = $this->user_tournament_entity->findUserHasARankInTournament($item->rank,$TOURNAMENT->id);
								$PRIZE = $this->prize_entity->init('id',$item->id);
							?>
						
							<div class="rowitem2">
								<div class="grid4">
									<?php echo getRankImage($item->rank,$TOURNAMENT->id, "style='float:left;margin-left:5px;margin-top:5px;margin-bottom:5px;'");?>
								</div>
								<div class="grid3" style="margin-top:5px;margin-bottom:3px;">
									<?php if($PRIZE->getLogo()) echo thumb($PRIZE->getLogoImage(),40,20);?> <br/>
									Product Value: <?php echo $PRIZE->getValue();?> <br/>
									Rank: <?php echo $PRIZE->getRank();?> <br/>
									<?php if($USER):?>
										Points Scored: <?php echo $this->user_tournament_entity->getMyPointInTournament($USER->getId(),$TOURNAMENT->id);?><br/>	
										City: <?php echo $USER->getCity();?><br/>
									<?php endif;?>
									<?php if($PRIZE->getDeliveryStatus()):?>
										Delivery Status: <?php echo $PRIZE->getDeliveryStatus();?><br/>
									<?php endif;?>
									<?php if($PRIZE->getProof() AND $PRIZE->getDeliveryStatus()):?>
										<a href="<?php echo $PRIZE->getProofTargetFileUrl();?>" target="_blank" style="color:#333333;">Proof</a>
									<?php endif;?>
								</div>
								<div class="grid2">
									<div style="text-align:center;float:left;margin-top:25px;width:100%;"> 
										<?php if($USER):?>
											<?php echo thumb($USER->getMyAvatar(),40,40);?>
										<?php endif;?>
									</div> 
									<span class="bold" style="width:100%;text-align:center;float:left;"><?php if($USER) echo $USER->getUserName();?></span>
								</div>
								
								<div class="clrboth"></div>
							</div>
							<div class="clrboth"></div>
						<?php endforeach; ?>	
					 <?php else: ?>
					 <div class="rowitem2">
						<div style="float:left;clear:both;padding:10px 0px 50px 10px;">
							Tournament Winners List will be updated as soon as the End of Tournament
						</div>
					 </div>	
					 <?php endif;?>
			</div>	
	</div>	 
</div>
